package cn.foolishbird.crow.mybatis.plus.handlers;

import org.apache.ibatis.reflection.MetaObject;

/**
 * MybatisPlus 自动填充配置
 *
 * @author L.cm
 */
public abstract class ClzMatchMetaObjectHandler<T> extends AbstractMetaObjectHandler {

    /**
     * class类型
     */
    private final Class<T> clz;

    public ClzMatchMetaObjectHandler(Class<T> clz) {
        this.clz = clz;
    }

    @Override
    protected boolean objectNeedInsertFill(MetaObject metaObject) {
        return this.clz.isAssignableFrom(metaObject.getOriginalObject().getClass());
    }

    @Override
    protected boolean objectNeedUpdateFill(MetaObject metaObject) {
        return this.clz.isAssignableFrom(metaObject.getOriginalObject().getClass());
    }

}
